package com.dailyblue.project.estate.controller;

import com.dailyblue.project.estate.commons.bean.Activity;
import com.dailyblue.project.estate.commons.util.JsonResult;
import com.dailyblue.project.estate.service.ActivityService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * @Auther:Liu
 * @Testname:ActivityController
 * @Date:2025/9/18 11:52
 */
@RestController
@RequestMapping("/activity")
@Slf4j
public class ActivityController {
    @Resource
    private ActivityService activityService;

    @PostMapping
    JsonResult saveActivity(Activity activity) {
        log.info("saveActivity");
        return activityService.saveActivity(activity);
    }

    @GetMapping("/{id}")
    JsonResult findOne(@PathVariable("id")String id){
        return activityService.findOneById(id);
    }

    @GetMapping
    JsonResult findAll(){
        return activityService.findAllActivity();
    }

    @DeleteMapping("/{id}")
    JsonResult deleteOne(@PathVariable("id")String id){
        return activityService.deleteActivity(id);
    }

    @PutMapping
    JsonResult updateOne(@RequestBody Activity activity){
        return activityService.updateActivity(activity);
    }
}
